﻿$(function () {
    EquipmentFind()
});

//仓库详情
function EquipmentFind() {
    layui.use('layer', function () {
        var form = layui.form;

        var workshopId = localStorage["workshopId"]
        // 创建表格实例
        $.ajax({
            url: "/Workshops/WorkshopsFinds",
            type: "get",
            data: {
                workshopId: workshopId,
            },
            success: function (data) {
                data = JSON.parse(data);
                console.log(data.data);
                // 在 ajax 请求成功后，使用正确的表格 ID 进行 reload
                $(data.data).each(function () {

                    $('#workshopNo').text(this.workshopNo)
                    $('#workshopName').text(this.workshopName)

                    //switch (this.workshopLocation) {
                    //    case 1:
                    //        $('#workshopLocation').text('位置一');
                    //        break;
                    //    case 2:
                    //        $('#workshopLocation').text('位置二');
                    //        break;
                    //    case 3:
                    //        $('#workshopLocation').text('位置三');
                    //        break;
                    //    default:
                    //}

                    if (this.workshopLocation === '1') {
                        $('#workshopLocation').text('位置一');
                    } else if (this.workshopLocation === '2') {
                        $('#workshopLocation').text('位置二');
                    } else if (this.workshopLocation === '3') {
                        $('#workshopLocation').text('位置三');
                    }

                    $('#workshopLeader').text(this.workshopLeader);
                    $('#workshopContact').text(this.workshopContact)
                    $("#workshopState").text(this.workshopState == 1 ? "正常" : "异常")
                    form.render();
                })
            }
        });
    })

    //本仓库的库区显示
    //ParticularsShowReservoir()
    ////本仓库的库区的全部库位显示
    //ParticularsShowSupplier()
}

function formatTime(timeStamp) {
    if (timeStamp) {
        var date = new Date(timeStamp);
        var year = date.getFullYear();
        var month = ('0' + (date.getMonth() + 1)).slice(-2);
        var day = ('0' + date.getDate()).slice(-2);
        var hour = ('0' + date.getHours()).slice(-2);
        var minute = ('0' + date.getMinutes()).slice(-2);
        var second = ('0' + date.getSeconds()).slice(-2);
        return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
    }
    return "";
}

